package com.neusoft.databus.common.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractModel;
import com.neusoft.databus.common.enums.DictionaryType;

import lombok.Getter;
import lombok.Setter;

/**
 * 字典表
 *
 * @author sunchf
 * @date 2019年3月18日 上午9:22:44
 */
@Getter
@Setter
@Entity
public class Dictionary extends AbstractModel {

    private static final long serialVersionUID = 1L;

    /** 字典编码 */
    @NotBlank(message = "字典编码不能为空")
    @Length(max = 255, message = "字典编码不能超过{max}位")
    @Column(length = 255, nullable = false, unique = true)
    private String code;

    /** 字典值 */
    @NotBlank(message = "字典值不能为空")
    @Length(max = 255, message = "字典值不能超过{max}位")
    @Column(length = 255, nullable = false)
    private String text;

    /** 字典类型 */
    @Enumerated(EnumType.STRING)
    @NotNull(message = "字典类型不能为空")
    @Column(length = 255, nullable = false)
    private DictionaryType dictionaryType;

    /** 显示排序 */
    private int sort = -1;

    /** 上级字典 */
    @ManyToOne
    private Dictionary parent;

}
